<?php

namespace app\api\controller\logistics;

use app\common\controller\qyg\Api;
use app\common\model\ExpressAssetslog;
use think\Exception;
use think\Request;

class Express extends Api
{
    public $noNeedRight = "*";

    public $service;

    public function __construct()
    {
        parent::__construct();
        $this->service= new \app\common\service\logistics\Express();
    }

    /**
     * 快递员入驻
     * @param Request $request
     * @return void
     */
    public function express_user(Request $request)
    {
        if(!$this->request->isPost()){
            $this->error("非法请求");
        }
        try {
            $res = $this->service->express_user($this->auth,$request);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 快递员申请信息
     * @return void
     */
    public function express_user_apply()
    {

        try {
            $res = $this->service->express_user_apply($this->auth->id);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 快递员信息
     * @return void
     */
    public function express_user_info()
    {
        try {
            $res = $this->service->express_user_info($this->auth->id);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 快递员信息
     * @return void
     */
    public function express_use_detail()
    {
        try {
            $express_id = $this->request->param("express_id");
            $res        = $this->service->express_user_info(null,$express_id);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 上传轨迹
     * @return void
     */
    public function express_track(Request $request)
    {
        if(!$this->request->isPost()){
            $this->error("非法请求");
        }
        try {
            $res = $this->service->express_track($this->auth->id,$request);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 添加收款信息
     * @return void
     */
    public function add_account(Request $request)
    {
        if(!$this->request->isPost()){
            $this->error("非法请求");
        }
        try {
            $res = $this->service->add_account($this->auth->id,$request);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 收款信息列表
     * @return void
     */
    public function account_list()
    {

        try {
            $res = $this->service->account_list($this->auth->id);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 发起提现
     * @return void
     */
    public function add_withdraw(Request $request)
    {
        if(!$this->request->isPost()){
            $this->error("非法请求");
        }
        try {
            $res = $this->service->add_withdraw($this->auth->id,$request);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 提现列表
     * @return void
     */
    public function withdraw_list(Request $request)
    {
        try {
            $res = $this->service->withdraw_list($this->auth->id,$request);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    /**
     * 提现详情
     * @return void
     */
    public function withdraw_detail(Request $request)
    {
        try {
            $res = $this->service->withdraw_detail($this->auth->id,$request);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }

    public function assets_log(Request  $request)
    {

        try {
            $res = $this->service->assets_log($this->auth->id,$request);
            $this->success("操作成功",$res);
        }catch (Exception $e){
            $this->error($e->getMessage());
        }
    }
}